package Demo01.Books;

import java.util.Comparator;

class CompareWithSale implements Comparator<Object> {
 
	@Override
	public int compare(Object o1, Object o2) {
		Book book1=(Book)o1;
		Book book2=(Book)o2;
		int hTOl =book2.sale-book1.sale;//后面的大于前面的
		return hTOl;
	}
	
}
//创建比较器 要求这次按照价格从低到高排序
class CompareWithPrice implements Comparator<Object>{
 
	@Override
	public int compare(Object o1, Object o2) {
		Book book3=(Book)o1;
		Book book4=(Book)o2;
		int lTOh=book3.price-book4.price;
		return lTOh;
	}
	
}
